<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="operlog-form">
                <div class="select-list">
                    <ul>
                        <li>
                            任务名称：<input type="text" name="jobName"/>
                        </li>
                        </li>
                        <li>
                            目的地：<select name="fndCityId" th:with="cityList=${@dict.getCity()}" data-live-search="true" liveSearchStyle="contains"  class="selectpicker" >
                            <option value="">所有</option>
                            <option th:each="city : ${cityList}" th:text="${city.CITY_FULL_NAME_EN}" th:value="${city.UUID}"></option>
                        </select>
                        </li>
                        <li>
                            创建人：<input type="text" name="createBy"/>
                        </li>
                        <li>
                            产品类型：<select name="productType">
                            <option value="">全部</option>
                            <option value="普通产品">普通产品</option>
                            <option value="远期产品">远期产品</option>
                            <option value="冷藏冷箱">冷藏冷箱</option>
                            <option value="冷藏非冷箱">冷藏非冷箱</option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-select-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:update:list')}]];
    var prefix = ctx + "business/update";

    $(function() {
        var options = {
            url: prefix + "/list",
            modalName: "任务",
            queryParams: queryParams,
            columns: [{
                checkbox: true
            },{
                title: "序号",
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
                {
                    field: 'id',
                    title: 'ID',
                    align: "center",
                },
                {
                    field: 'jobName',
                    title: '任务名称',
                    align: "center",
                },
                {
                    field: 'productType',
                    title: '产品类型',
                    align: "center",
                    formatter: function(value, row, index) {
                        return '<div style="width:100px;">'+value+'</div>';
                    }
                },
                {
                    field: 'porCityName',
                    title: '出发地(中文)',
                    align: "center"
                },
                {
                    field: 'fndCityName',
                    title: '目的地(中文)',
                    align: "center"
                },
                {
                    field: 'twentyGPCount',
                    title: '20GP数量',
                    align: "center"
                },
                {
                    field: 'fortyGPCount',
                    title: '40GP数量',
                    align: "center"
                },
                {
                    field: 'fortyHQCount',
                    title: '40HQ数量',
                    align: "center"
                },
                {
                    field: 'twentyRFCount',
                    title: '20RF数量',
                    align: "center"
                },{
                    field: 'fortyRQCount',
                    title: '40RQ数量',
                    align: "center"
                },
                {
                    field: 'isFor',
                    title: '执行类型',
                    align: "center",
                    formatter: function(value, row, index) {
                        if(value == 2){
                            return '<div style="width:100px;color: green">秒杀</div>';
                        }else if (value == 3){
                            return '<div style="width:100px;color: red">自杀</div>';
                        }
                    }
                },
                {
                    field: 'createBy',
                    title: '创建人',
                    align: "center"
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    align: "center",
                    formatter: function(value, row, index) {
                        return '<div style="width:150px;">'+value+'</div>';
                    }
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>自杀模式</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit2(\'' + row.id + '\')"><i class="fa fa-edit"></i>秒杀模式</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });
    function queryParams(params) {
        var search = $.table.queryParams(params);
        return search;
    }

    function searchPre() {
        $.table.search('operlog-form', 'bootstrap-table');
    }

    function resetPre() {
        $("#operlog-form")[0].reset();
        $.table.search('operlog-form', 'bootstrap-table');
    }

    function add() {
        $.operate.add();
    }

    function edit(id) {
        var value = prompt("请输入修改密码","")
        console.log("value==:"+value)
        if(value.toString().trim().length >= 6){
            $.operate.get(prefix +"/edit/"+ id+"-"+value);
        }else{
            alert("密码错误")
        }
    }

    function edit2(id) {
        var value = prompt("请输入修改密码","")
        console.log("value==:"+value)
        if(value.toString().trim().length >= 6){
            $.operate.get(prefix +"/edit2/"+ id+"-"+value);
        }else{
            alert("密码错误")
        }
    }
</script>
</body>
</html>
